﻿using DSTMEETING.Web.Api.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DSTMEETING.Win.App.Views
{
    /// <summary>
    /// LoadingView.xaml 的交互逻辑
    /// </summary>
    public partial class LoadingView : UserControl
    {
        public LoadingView()
        {
            InitializeComponent();

            LoadConfig();
        }

        private async void LoadConfig()
        {
            using(HttpClient client = HttpClientFactory.Create())
            {
                try
                {
                    var response = await client.GetAsync("api/config/loadsettings?version=1&platform=windows");
                    var result = await response.Content.ReadAsAsync<DSTMEETING.Data.ApiResult<DSTMEETING.Web.Api.Contracts.ConfigLoadSettingsResult>>();

                    //ViewNavigator.Switch(new LoginView());
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            ViewNavigator.Switch(new LoginView());
        }
    }
}
